<?php

/*

  Action	$4

  Gain a card costing up to $4. If it is an... Action card, +1 Action. Treasure card, +$1. Victory card, +1 Card.

 */

class Ironworks extends Card implements iAction, iKingdom, iIntrigue {

    public function __construct() {
        parent::__construct("Ironworks", 4);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "Gain a card costing up to $4. If it is an... Action card, +1 Action. Treasure card, +$1. Victory card, +1 Card.");
    }
    
    public function play(Game $game, $isRealCard) {
        $four_or_less_cards = $game->getBoardCardsByPrice(new Price(), new Price(4));

        $output = MySocket::GetUserReply($game, Input_ChooseOne, $four_or_less_cards, 1, 1, null, "Choose a card");
        $card_name = $output[0];
        $card = $game->moveCardFromPileToPile($card_name, BoardCards, DiscardPile);
         ScreenDisplay::addScreenMessage($game, true, "gain " . nicePrint($card), "gains " .ScreenDisplay::$LMSG);

        if ($card instanceof iAction) {
            $game->addActions(1);
             ScreenDisplay::addScreenMessage($game, false, " and get +1 action", " and gets +1 action");
        }

        if ($card instanceof iTreasure) {
            $game->addMoney(new Price(1));
             ScreenDisplay::addScreenMessage($game, false, " and get +1$", " and gets +1$");
        }

        if ($card instanceof iVictory) {
            $drawed_cards = $game->drawCards(1);
             ScreenDisplay::addScreenMessage($game, false, " and draw " . nicePrint($drawed_cards), " and draws ".sizeof($drawed_cards). " cards");
        }

        $game->cardActionFinished();
        return true;
    }

}

?>